package com.smartfactory.sail.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smartfactory.sail.mapper.CommonMapper;
import com.smartfactory.sail.service.ICommonService;
import com.smartfactory.sail.utils.PageUtils;
import com.smartfactory.sail.vo.PageParam;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author 王巨壁
 * @title: CommonServiceImpl
 * @projectName smart-sail
 * @description: TODO
 * @date 2019/8/418:05
 */
@Service
public class CommonServiceImpl implements ICommonService {

    private CommonMapper commonMapper;

    public CommonServiceImpl(CommonMapper commonMapper) {
        this.commonMapper = commonMapper;
    }

    @Override
    public List<Map<String, Object>> listByPageAndQueryParam(Map queryParam, PageParam pageParam, String sql) {
        Page<Map<String,Object>> page = new Page<>();
        PageUtils.createPage(page, pageParam);
        QueryWrapper<Map<String,Object>> query = new QueryWrapper<>();
        query.allEq(queryParam);
        return commonMapper.getListPageByQueryParams(page, query, sql);
    }
}
